package controller;
import java.util.List;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import pojo.Customer;
import service.CustomerManager;
import service.impl.CustomerManagerFactory;
@Controller
public class CustomerController {
	private CustomerManager manager;
	public CustomerController()
	{
		manager=CustomerManagerFactory.getInstance();
	}
	
	@RequestMapping(value="/addCustomer",method=RequestMethod.POST)
	@ResponseBody
	public Customer addCustomer(@RequestBody Customer c)
	{
		manager.addCustomer(c);
		return c;
	}
	
	@RequestMapping(value="/deleteCustomer",method=RequestMethod.DELETE)
	@ResponseBody
	public Customer deleteCustomer (String cid)
	{
		Customer customer=manager.deleteCustomerById(cid);
		return customer;
	}
	@RequestMapping(value="/findAll")
	@ResponseBody
	public List<Customer> findAll(Customer c)
	{
		List<Customer> customers=manager.findAll();
		return customers;
	}
	
}
